package com.prism.moodme.app;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagLayout;
import java.awt.Image;
import javax.swing.JPanel;
import com.prism.moodme.util.ImageHelper;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.border.EtchedBorder;


public class MapPanel extends JPanel {
	/**
	 *
	 */
	private static final long serialVersionUID = -8781878000336752710L;

	private static final String defMap = "http://maps.google.com/maps/api/staticmap?zoom=14&maptype=roadmap&sensor=true&center=30.616270010132528,-96.31062205944113&size=400x500&markers=30.616224863920568,-96.3107915022079";  //  @jve:decl-index=0:

	private Image image;  //  //  @jve:decl-index=0:
//	private URL url;
	/**
	 * This is the default constructor
	 */
	public MapPanel(String image) {
		super();
		setImage(image);
		initialize();
	}

	public MapPanel() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 *
	 * @return void
	 */
	private void initialize() {
		this.setLayout(null);
		this.setSize(new Dimension(400, 500));
		this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
		this.setPreferredSize(new Dimension(400, 495));
		setMap();
	}

	public void setMap(){
		setMap(defMap);
	}

	public void setMap(String map){
		setImage(map);
		repaint();
	}
    public void paint(Graphics g) {
        Graphics2D g2D = (Graphics2D)g;
        g2D.drawImage(image, 0, 0, this);

    }

    public void setImage(String image){
    	this.image = ImageHelper.loadImage(image);
    }
}
